/**
 * Created by zzy on 2017/9/7.
 */
import {observable, action, computed, observe} from 'mobx'
import {observer} from 'mobx-react/native'

class WaterTiketStore{
    @observable _productModel;
    @observable _commonModels=[];
    constructor(productModel){
        this._productModel=productModel;
    }
    @action clearData(){
        this._productModel=new ProductModel();
        this._commonModels=null;
    }
    @action setProductItemModels(productInfo){
         this.clearData();
         this._productModel.setProductModel(productInfo.productModel);
         this._commonModels=productInfo.commonModels;
    }
    @computed get productModel(){
        return this._productModel;
    }
    @computed get commonModels(){
        return this._commonModels;
    }

}
class ProductModel{
    @observable _name;
    @observable _imageUrl;
    @observable _type;
    @observable _volume;
    @observable _productItemModels=[];
    @observable _activePolicyIndex=0;
    @observable _collectProductFlg=false;
    @observable _ticketProductItemId;
    constructor(){
        this._productItemModels.push(new ProductItemModel(0,0,0,0,0,'',[],[],'',0))
    }
    @action setProductModel(productItemModel){
        this._name=productItemModel.name;
        this._imageUrl=productItemModel.imageUrl;
        this._type=productItemModel.type;
        this._volume=productItemModel.volume;
        this._collectProductFlg=productItemModel.collectProductFlg;
        this._ticketProductItemId=productItemModel.ticketProductItemId;
        this._productItemModels.clear();
        productItemModel.productItemModels.map((productItemModel)=>{
            this._productItemModels.push(new ProductItemModel(productItemModel.productItemId,productItemModel.originalPrice,productItemModel.currentPrice,
                productItemModel.selectCount,productItemModel.saleMount,productItemModel.name,productItemModel.productImage,productItemModel.productDetailPictures
            ,productItemModel.productCategory,productItemModel.baseCount))
        });
    }
    @computed get name(){
        return this._name;
    }
    @computed get imageUrl(){
        return this._imageUrl;
    }
    @computed get type(){
        return this._type;
    }
    @computed get productItemModels(){
        return this._productItemModels;
    }
    @computed get activePolicyIndex(){
        return this._activePolicyIndex;
    }
    @action setActivePolicyIndex(i){
        this._activePolicyIndex=i;
    }
    @computed get ActiveProductItemModel(){

        return this._productItemModels[this._activePolicyIndex];
    }
    @computed get CollectProductFlg(){
        return this._collectProductFlg;
    }
    @computed get Volume(){
        return this._volume;
    }
    @computed get TicketProductItemId(){
        return this._ticketProductItemId;
    }
}
class ProductItemModel{

    @observable _productItemId;
    @observable _originalPrice;
    @observable _currentPrice;
    @observable _selectCount;
    @observable _saleMount;
    @observable _name;
    @observable _productImage;
    @observable _productDetailPictures;
    @observable _productCategory;
    @observable _baseCount=0;
    constructor(productItemId,originalPrice,currentPrice,selectCount,saleMount,name,productImage,productDetailPictures,productCategory,baseCount){
        this._productItemId=productItemId;
        this._originalPrice=originalPrice;
        this._currentPrice=currentPrice;
        this._selectCount=selectCount;
        this._saleMount=saleMount;
        this._name=name;
        this._productImage=productImage;
        this._productDetailPictures=productDetailPictures;
        this._productCategory=productCategory;
        this._baseCount=baseCount;
    }

    @computed get productItemId(){
        return this._productItemId;
    }
    @computed get originalPrice(){
        return this._originalPrice;
    }
    @computed get currentPrice(){
        return this._currentPrice;
    }
    @computed get selectCount(){
        return this._selectCount;
    }
    @computed get saleMount(){
        return this._saleMount;
    }
    @computed get name(){
        return this._name;
    }
    @computed get productImage(){
        return this._productImage;
    }
    @computed get productDetailPictures(){
        return this._productDetailPictures;
    }
    @computed get productCategory(){
        return this._productCategory;
    }
    @computed get baseCount(){
        return this._baseCount;
    }
}
class CommonModel{
    @observable comment='';
    @observable userName='';
    @observable commentTime='';
    @observable userIconUrl='';
    @observable score='';
    @observable imageUrlList=[];
}
let productModel=new ProductModel();
let waterTiketStore=new WaterTiketStore(productModel);
export default waterTiketStore;